# Contributor: Leon Marz <main@lmarz.org>
# Maintainer: Leon Marz <main@lmarz.org>
pkgname=opencl
pkgver=2024.05.08
pkgrel=0
pkgdesc="OpenCL ICD Loader"
url="https://khronos.org/opencl"
arch="all"
license="Apache-2.0"
makedepends="cmake samurai linux-headers"
depends_dev="$pkgname-headers"
subpackages="$pkgname-headers:headers:noarch $pkgname-layer-info $pkgname-dev"
provides="opencl-icd-loader=$pkgver-r$pkgrel"
source="https://github.com/KhronosGroup/OpenCL-SDK/releases/download/v$pkgver/OpenCL-SDK-v$pkgver-Source.tar.gz"
options="!check" # tests are not functioning correctly
builddir="$srcdir/OpenCL-SDK-v$pkgver-Source"

prepare() {
	default_prepare

	# build artifacts are somehow included...
	rm -rf "$builddir/build"
}

build() {
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_INSTALL_DATADIR=lib \
		-DCMAKE_BUILD_TYPE=None \
		-DOPENCL_SDK_BUILD_SAMPLES=OFF
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

headers() {
	pkgdesc="OpenCL development headers"
	amove usr/include
}

info() {
	pkgdesc="OpenCL Layer Info tool"

	amove usr/bin/cllayerinfo
}

sha512sums="
53d3a5f0086a192b20062ada9fdff9a49375dea954961fdb17fc7e8c174c3dc791a903b38fa9021eb680d854a9835fc1777dc5475974c37cb79ed07d722583ea  OpenCL-SDK-v2024.05.08-Source.tar.gz
"
